package hsmgpslogger.client;

import hsmgpslogger.shared.PositionInfo;

import com.google.gwt.maps.client.InfoWindow;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.event.MarkerClickHandler;
import com.google.gwt.maps.client.overlay.Marker;

public class MarkerFactory {
	
	public static Marker getHiResMarker(final PositionInfo pi, final MapWidget map) {
		Marker m = getMarker(pi, map);
		return m;
	}

	public static Marker getMedResMarker(final PositionInfo pi, final MapWidget map) {
		Marker m = getMarker(pi, map);
		return m;
	}
	
	public static Marker getLoResMarker(final PositionInfo pi, final MapWidget map) {
		Marker m = getMarker(pi, map);
		return m;
	}
	
	private static Marker getMarker(final PositionInfo pi, final MapWidget map) {
		final Marker m = new Marker(pi.getLatLng());
		m.addMarkerClickHandler(new MarkerClickHandler() {
		      public void onClick(MarkerClickEvent event) {
		        InfoWindow info = map.getInfoWindow();
		        info.open(m,new InfoWindowContent(pi.toHTML()));
		      }
		    });
		return m;
	}
}
